var express = require('express');
var router = express.Router();
var cookieParser = require('cookie-parser');

var router = express.Router();
router.use(cookieParser());

/* GET home page. */
router.get('/', function(req, res, next) {
  //res.render('index', { title: 'Express' });
  res.send('首页');
});

router.get('/set',(req,res)=>{
  res.cookie('userName','橘子',{
    maxAge:20000,
    httpOnly:true
  })
  res.send('设置cookie成功！');
});

router.get('/get',(req,res)=>{
  res.send('获取cookie为：' + req.cookies.userName);
});

module.exports = router;
